-- @owner: opentestcase023
-- @date: 2022/02/24
-- @testpoint: 在创建的unlogged table上创建触发器,合理报错

--step1:建表;expect:成功
drop table if exists t_unlogged;
drop table if exists t_trigger_des;
create unlogged table t_unlogged (col_1 int);
create table t_trigger_des(id1 int, id2 int, id3 int) with (storage_type=ustore);
--step2:在创建的unlogged table上创建触发器;expect:合理报错
create or replace function tri_insert_func() returns trigger as
$$
declare
begin
insert into t_trigger_des values(new.id1, new.id2, new.id3);
return new;
end
$$ language plpgsql;
/
drop trigger if exists insert_trigger on t_unlogged cascade;
create trigger insert_trigger before insert on t_unlogged
        for each row 
		execute procedure tri_insert_func();
/
--step3:清理环境;expect:成功
drop trigger if exists insert_trigger on t_unlogged cascade;
drop table if exists t_unlogged cascade;
drop table if exists t_trigger_des cascade;
